package portada.server.serviciosBD;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import portada.domain.Post;
import portada.server.HibernateUtil;

public class ServicioPostBD {

	public List getPosts() {
		Session newSession = HibernateUtil.currentSession();
		Transaction newTransaction = newSession.beginTransaction();
		Query q = newSession.createQuery("from " + Post.class.getName());
		List resultado = q.list();
		newTransaction.commit();
		System.out.println("consulte posts");
		return resultado;

	}
	public void alta(Post post) {
		Session newSession = HibernateUtil.currentSession();
		Transaction newTransaction = newSession.beginTransaction();
		newSession.save(post);
		newTransaction.commit();
		System.out.println("pase por alta en la parte server");
		
	}
}
